package com.aisile.admin.config;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @Auther:yry
 * @Date:2024/1/3 0003
 * @VERSON:1.0
 */
@Configuration
public class FeignTokenConfig implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        //String token =  requestAttributes.getRequest().getHeader("token");
        String token = "eyJhbGciOiJIUzUxMiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAAADWLQQqEMAxF75K1BVNTW71NaytEZqCQCop490kXs_n8x-M9cDSGFXZES3nKJtttN5R0wpZmE2i0xQUXaZlgAI4NVvQjBY-IbgA5k9ZySyvf7kUUIwt_imI8c8da9Zer_lPyPWV19v0BJdDePIEAAAA.7Qy9sk2s-nxBlWqJ85csfKXnwBRhIurSkLljL5BOI51VkK0HiEFjDCrfJvXWV1yg0yrsB1Q79f3xUDK_vPnRhw";
        // 请求之前 携带token就行了
        requestTemplate.header("token",token);
    }
}
